package com.twu.biblioteca.repository;

import com.twu.biblioteca.common.UserRole;
import com.twu.biblioteca.entity.User;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created by ccsong on 9/23/14.
 */
public class UserRepository {
    private static List<User> userList = new ArrayList<User>();
    public UserRepository(){
        userList.add(new User("100-0001","librarian","libr@thoughtworks.com","18789311118",UserRole.Librarian));
        userList.add(new User("000-0001","Zhang San","sz@thoughtworks.com","18792937110",UserRole.Customer));
        userList.add(new User("000-0010","Li Ming","ml@thoughtworks.com","18792938273", UserRole.Customer));
        userList.add(new User("000-0011","Zhao Liang","lz@thoughtworks.com","18792938455",UserRole.Customer));
        userList.add(new User("000-0100","Zhao Xiao Liang","lxz@thoughtworks.com","18892938455",UserRole.Customer));
    }
    public User getUserInfo(String libraryNumber){
        Iterator iterator = userList.listIterator();
        User user;
        while(iterator.hasNext()){
            user = (User)iterator.next();
            if(user.getLibraryNumber().equals(libraryNumber)){
                return user;
            }
        }
        return null;
    }
}
